#include <pktbuilder.h>
#include <assert.h>
#include <vector>

using namespace pktbuilder::TCP;
int main() {
	std::vector<uint8_t> data({
			0xa5, 0xc0, 0x00, 0x50, 0xd3, 0x86, 0xf0, 0x81, 0xda, 0x59, 0x42, 0x64, 0x80, 0x18, 0x02, 0x00,
			0xfe, 0x71, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x0b, 0xee, 0x6e, 0x09, 0x0b, 0xee, 0x6e, 0x09,
			0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a,
			0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x0d,
			0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63, 0x75, 0x72,
			0x6c, 0x2f, 0x37, 0x2e, 0x38, 0x31, 0x2e, 0x30, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74,
			0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d, 0x0a});
	Packet pkt = Packet::decodeFrom(data);
	assert(pkt.getSourcePort() == 42432);
	assert(pkt.getDestinationPort() == 80);
	assert(pkt.getSequenceNumber() == 3548835969);
	assert(pkt.getAckNumber() == 3663282788);
	assert(pkt.getFlags() == (Flag::PSH | Flag::ACK));
	assert(pkt.getWindowSize() == 512);
	assert(pkt.getUrgentPointer() == 0);
	assert(pkt.getOptions().size() == 1);
	assert(pkt.getOptions()[0].option_kind == OptionCode::TIMESTAMP);
	assert(pkt.getOptions()[0].option_data == std::vector<uint8_t>({0x0b, 0xee, 0x6e, 0x09, 0x0b, 0xee, 0x6e, 0x09}));
	assert(pkt.getPayload() == std::vector<uint8_t>({
				0x47, 0x45, 0x54, 0x20, 0x2f, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a,
				0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x0d,
				0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x63, 0x75, 0x72,
				0x6c, 0x2f, 0x37, 0x2e, 0x38, 0x31, 0x2e, 0x30, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74,
				0x3a, 0x20, 0x2a, 0x2f, 0x2a, 0x0d, 0x0a, 0x0d, 0x0a}));
}
